package com.floreo.shopping.service;

import com.floreo.shopping.model.Group;
import com.floreo.shopping.model.Product;
import com.floreo.shopping.model.Quantity;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * @author merzod
 */
public class QuantityServiceTest {

    private IQuantityService service;

    @Before
    public void setUp() throws Exception {
        service = ServiceFactory.getInstance().getQuantityService();
    }

    @Test
    public void testRegisterQuantities() throws Exception {
        Quantity quantity1 = new Quantity();
        Quantity quantity2 = new Quantity();
        Quantity quantity3 = new Quantity();
        Product product1 = new Product("milk", new Group());
        Product product2 = new Product("bread", new Group());
        service.registerQuantities(product1, quantity1);
        service.registerQuantities(product2, quantity2, quantity3);
        Assert.assertEquals(1, service.getQuantities(product1).size());
        Assert.assertTrue(service.getQuantities(product1).contains(quantity1));
        Assert.assertEquals(2, service.getQuantities(product2).size());
        Assert.assertTrue(service.getQuantities(product2).contains(quantity2));
        Assert.assertTrue(service.getQuantities(product2).contains(quantity3));
    }
}
